package com.hd.sup.modules.vehicle.model;

import java.io.Serializable;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.baomidou.mybatisplus.annotation.TableName;
import com.hd.common.utils.DateUtil;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.Date;

/**
 * <p>
 * 车辆离线、在线状态
 * </p>
 *
 * @author chentl123
 * @since 2020-12-28
 */
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
@Data
@TableName("sp_vehicle_on_off")
public class VehicleOnOff extends Model<VehicleOnOff> {

    private static final long serialVersionUID = 1L;

    //查询构造
    public VehicleOnOff(String startDateStr, String endDateStr, String dateRange, String enterpriseNo, String platNo, String enterpriseName, String regionCode, Integer onlineStatus, String sort, String order) {
        this.startDateStr = startDateStr;
        this.endDateStr = endDateStr;
        this.dateRange = dateRange;
        this.enterpriseNo = enterpriseNo;
        this.platNo = platNo;
        this.enterpriseName = enterpriseName;
        this.regionCode = regionCode;
        this.onlineStatus = onlineStatus;
        this.sort = sort;
        this.order = order;
    }

    //插入构造
    public VehicleOnOff(String platNo, String platNoColor, Date onlineTime, Date offTime, Integer onlineStatus, String distance) {
        this.platNo = platNo;
        this.platNoColor = platNoColor;
        this.onlineTime = onlineTime;
        this.offTime = offTime;
        //计算在线时长
        this.duration = DateUtil.getDiffSeconds(offTime, onlineTime);
        this.onlineStatus = onlineStatus;
        this.distance = distance;
    }

    /**
     * id
     */
    private String id;
    /**
     * 车牌号
     */
    @TableField("plat_no")
    private String platNo;
    /**
     * 车牌颜色
     */
    @TableField("plat_no_color")
    private String platNoColor;
    /**
     * 上线时间
     */
    @TableField("online_time")
    private Date onlineTime;
    /**
     * 下线时间
     */
    @TableField("off_time")
    private Date offTime;
    /**
     * 在线时长
     */
    private String duration;
    /**
     * 在线状态 | 0 离线 1 在线
     */
    @TableField("online_status")
    private Integer onlineStatus;
    /**
     * 行驶里程 | km
     */
    private String distance;

    /**
     * 筛选开始时间
     */
    @TableField(exist = false)
    private String startDateStr;
    /**
     * 筛选结束时间
     */
    @TableField(exist = false)
    private String endDateStr;
    /**
     * 日期范围
     */
    @TableField(exist = false)
    private String dateRange;
    /**
     * 企业编码
     */
    @TableField(exist = false)
    private String enterpriseNo;
    /**
     * 企业名称
     */
    @TableField(exist = false)
    private String enterpriseName;
    /**
     * 行政编码
     */
    @TableField(exist = false)
    private String regionCode;
    @TableField(exist = false)
    private String sort;
    @TableField(exist = false)
    private String order;


    @Override
    protected Serializable pkVal() {
        return this.id;
    }
}
